﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kavaa.Core.Tracing;
using Kavaa.Core.Data;
using System.Data.SqlClient;
using System.Collections;
using Kavaa.Modules.PortailMedical.Entity;
using Kavaa.Modules.PortailMedical.Datalayer;

namespace Kavaa.Modules.PortailMedical.Datalayer
{
    class VilleDAO
    {
        public static Villes GetVilles()
        {
           
            Villes villes = new Villes();

            foreach (var row in SqlDaoAdapter.ExecuteReader(
                ConfigurationCache.DatabaseConnectionString,
                "[dbo].[sp_PortailMedical_GetVilles]"
           ))
            {
                villes.Add(new Ville()
                {
                    Id = (row["VilleId"] != DBNull.Value) ? Convert.ToInt32(row["VilleId"]) : 0,
                    Name = (row["VilleName"] != DBNull.Value) ? Convert.ToString(row["VilleName"]) : null,
                });
            }

            return villes;
        }

    }


}
